#pragma once
#include "DSphere.h"
#include "../DSpace.h"
#include "../DVector3.h"

namespace Skill
{
	namespace Ode
	{		
		DSphere::DSphere(DSpace^ space, dReal radius)
			:DGeometry(space)
		{
			dSpaceID s = space? space->_Space() : NULL; 
			_SetPointer(dCreateSphere(s,radius),true);	
			if(_Container)
						_Container->AddSpace(this);
		}
		dReal DSphere::Radius::get()
		{
			if(IsSpace) return Single::NaN;
			return dGeomSphereGetRadius(_Geom()); 
		}
		void DSphere::Radius::set(dReal value)
		{
			if(IsSpace) return;
			dGeomSphereSetRadius(_Geom(),value); 
		}

		dReal DSphere::PointDepth(dReal x, dReal y, dReal z)
		{
			if(IsSpace) return Single::NaN;
			return dGeomSpherePointDepth(_Geom(), x, y, z);
		}
		dReal DSphere::PointDepth(DVector3^ p)
		{
			if(IsSpace) return Single::NaN;
			return dGeomSpherePointDepth(_Geom(),p->_This[0], p->_This[1], p->_This[2]);
		}
	}
}